GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.
Completed
Push — master ( 82b9d9...562a49 )
by Vladimir
38s
created

index.test.js ➔ ???   B

Complexity

Conditions 1
Paths 1

Size

Total Lines 77

Duplication

Lines 0
Ratio 0 %

Importance

Changes 3
Bugs 0 Features 0
Metric Value
cc 1
c 3
b 0
f 0
nc 1
dl 0
loc 77
rs 8.9342
nop 0

1 Function

Rating   Name   Duplication   Size   Complexity  
A index.test.js ➔ ... ➔ ??? 0 14 1

How to fix   Long Method   

Long Method

Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.

For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.

Commonly applied refactorings include:

1
const router = require('./../../../src/routes/index');
2
3
describe('Index routes.', () => {
4
  test('GET homepage', (done) => {
5
    const request = {
6
      method: 'GET',
7
      url: '/',
8
    };
9
    const response = {
10
      redirect: (targetUrl) => {
11
        expect(targetUrl).toMatch(/.+/);
12
        done();
13
      },
14
    };
15
16
    router.handle(request, response);
17
  });
18
19
  test('GET page by streamId', (done) => {
20
    const request = {
21
      method: 'GET',
22
      url: '/testId',
23
    };
24
    const response = {
25
      render: (tpl, data) => {
26
        expect(tpl).toBe('index');
27
        expect(typeof data).toBe('object');
28
        done();
29
      },
30
    };
31
32
    router.handle(request, response);
33
  });
34
35
  /**
36
   * This block describes test cases related to POSTing data into page.
37
   */
38
  describe('POST data into page with certain streamId.', () => {
39
    const request = {
40
      method: 'POST',
41
      url: '/testId',
42
      headers: {
43
        'content-type': 'application/json',
44
      },
45
      connection: {
46
        socket: {
47
          remoteAddress: 'testIp',
48
        },
49
      },
50
      socket: {},
51
      body: 'RAW Body.',
52
    };
53
    /** global: jest */
54
    const response = {
55
      status: jest.fn(),
56
      send: jest.fn(),
57
    };
58
59
    test('POST JSON', (done) => {
60
      request.body = '{"decs": "JSON data"}';
61
      global.socket = {
62
        emit: (type, data) => {
63
          expect(type).toBe('log');
64
          expect(typeof data).toBe('object');
65
          done();
66
        },
67
      };
68
69
      router.handle(request, response);
70
    });
71
72
    test('POST plain text', (done) => {
73
      request.headers['content-type'] = 'text';
74
      response.send = () => done();
75
76
      router.handle(request, response);
77
    });
78
  });
79
});
80